package wodegua.d16_algorithm;

import java.util.Arrays;

public class SelectSortTest {
    public static void main(String[] args) {
        /**
         * 选择排序
         * 每轮选择当前位置，开始找出后面的较小值与该位置交换
         */
        int[] arr = {3,5,6,8,9,1,2,7,10,4};
        for (int i = 0; i < arr.length - 1; i++) {
            /**
             * 0 - 1-9
             * 1 - 2-9
             * 2 - 3-9
             * 3 - 4-9
             */
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[j] < arr[i]) {
                    int temp = arr[j];
                    arr[j] = arr[i];
                    arr[i] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
